﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Exhibition
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        int i = 0;
        public MainWindow()
        {
            InitializeComponent();

            //this.Left = 100.0;
            //this.Top = 100.0;
            //this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
            //this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;  

            ScheduleNavCanvas.Visibility = System.Windows.Visibility.Hidden;
            MyScrolViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
        }

        private void CheckImageHeight(double height)
        {
            if (height > 1920)
            {
                MyScrolViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            }
            else
            {
                MyScrolViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
            }
        
        }

        private void HomeBtn_Click(object sender, RoutedEventArgs e)
        {
            ScheduleNavCanvas.Visibility = System.Windows.Visibility.Hidden;
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Home.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearHover();
            var brush = new ImageBrush();
            brush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/home-button-selected.png"));
            HomeBtn.Background = brush;

            
        }

        private void ScheduleBtn_Click(object sender, RoutedEventArgs e)
        {
            ScheduleNavCanvas.Visibility = System.Windows.Visibility.Visible;
            
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Monday.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearHover();
            ClearScheduleHover();

            var brush = new ImageBrush();
            brush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/schedule-button-selected.png"));
            ScheduleBtn.Background = brush;

            var brushMonday = new ImageBrush();
            brushMonday.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/Monday-button-selected.png"));
            MondayBtn.Background = brushMonday;
        }

        private void VenueBtn_Click(object sender, RoutedEventArgs e)
        {
            ScheduleNavCanvas.Visibility = System.Windows.Visibility.Hidden;
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Venue Map.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearHover();
            var brush = new ImageBrush();
            brush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/venue_map-button-selected.png"));
            VenueBtn.Background = brush;
        }

        private void KeyNoteBtn_Click(object sender, RoutedEventArgs e)
        {
            ScheduleNavCanvas.Visibility = System.Windows.Visibility.Hidden;
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Keynotes.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearHover();
            var brush = new ImageBrush();
            brush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/keynotes-button-selected.png"));
            KeyNoteBtn.Background = brush;
        }

        private void SponsorsBtn_Click(object sender, RoutedEventArgs e)
        {
            
            ScheduleNavCanvas.Visibility = System.Windows.Visibility.Hidden;
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Sponsors.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearHover();
            var brush = new ImageBrush();
            brush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/sponsors-button-selected.png"));
            SponsorsBtn.Background = brush;

        }


        private void ClearHover()
        {
            var brushHome = new ImageBrush();
            brushHome.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/home-button.png"));
            HomeBtn.Background = brushHome;

            var brushExhibitors = new ImageBrush();
            brushExhibitors.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/keynotes-button.png"));
            KeyNoteBtn.Background = brushExhibitors;

            var brushSchedule = new ImageBrush();
            brushSchedule.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/schedule-button.png"));
            ScheduleBtn.Background = brushSchedule;

            var brushSponsors = new ImageBrush();
            brushSponsors.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/sponsors-button.png"));
            SponsorsBtn.Background = brushSponsors;

            var brushVenue = new ImageBrush();
            brushVenue.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/venue_map-button.png"));
            VenueBtn.Background = brushVenue;

            var brushHighLights = new ImageBrush();
            brushHighLights.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/highlights-button.png"));
            HighLightsBtn.Background = brushHighLights;
        }

        private void MondayBtn_Click(object sender, RoutedEventArgs e)
        {
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Monday.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearScheduleHover();

            var brushMonday = new ImageBrush();
            brushMonday.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/Monday-button-selected.png"));
            MondayBtn.Background = brushMonday;
        }

        private void TuesdayBtn_Click(object sender, RoutedEventArgs e)
        {
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Tuesday.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearScheduleHover();

            var brushTuesday = new ImageBrush();
            brushTuesday.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/Tuesday-button-selected.png"));
            TuesdayBtn.Background = brushTuesday;
        }

        private void WednesdayBtn_Click(object sender, RoutedEventArgs e)
        {
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/wednesday.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearScheduleHover();

            var brushWednesday = new ImageBrush();
            brushWednesday.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/Wednesday-button-selected.png"));
            WednesdayBtn.Background = brushWednesday;
        }

        

        private void ClearScheduleHover()
        {
            var brushMonday = new ImageBrush();
            brushMonday.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/Monday-button.png"));
            MondayBtn.Background = brushMonday;

            var brushTuesday = new ImageBrush();
            brushTuesday.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/Tuesday-button.png"));
            TuesdayBtn.Background = brushTuesday;

            var brushWednesday = new ImageBrush();
            brushWednesday.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/Wednesday-button.png"));
            WednesdayBtn.Background = brushWednesday;


        }
        
        private void NavCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            i += 1;
            System.Timers.Timer t = new System.Timers.Timer(600);
            t.Interval = 600;

            t.Elapsed += (s, ee) => { t.Enabled = false; i = 0; };
            t.Enabled = true;
            if (i % 2 == 0)
            {
                t.Enabled = false;
                this.Close();
                i = 0;
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Opacity = 0.0;
            DoubleAnimation OpercityAnimation = new DoubleAnimation(0.01, 1.00, new Duration(TimeSpan.FromSeconds(2.4)));
            this.BeginAnimation(Window.OpacityProperty, OpercityAnimation);
        }

        private void HighLightsBtn_Click(object sender, RoutedEventArgs e)
        {
            this.HighLightsBtn.BringIntoView();
            ScheduleNavCanvas.Visibility = System.Windows.Visibility.Hidden;
            BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Image/Highlights-SCCC-Monday.png"));
            BodyImage.Source = image;

            CheckImageHeight(image.PixelHeight);

            ClearHover();
            var brush = new ImageBrush();
            brush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Assets/highlights-button-selected.png"));
            HighLightsBtn.Background = brush;

        }
        
    }
}
